import { observable } from "mobx";
import http from 'libs/http';

class Store {
  @observable records = [];
  @observable record = {};
  @observable selectedRows = [];
  @observable isFetching = false;
  @observable formVisible = false;
  @observable qrcodeVisible = false;

  // 搜索条件
  @observable f_name;
  @observable f_year;
  @observable f_status;

  fetchRecords = () => {
    this.isFetching = true;
    return http.get('/api/course/')
      .then(res => {
        console.log(res);
        this.records = res;
      })
      .finally(() => this.isFetching = false)
  };

  showForm = (info = {}) => {
    this.formVisible = true;
    this.record = info;
  };

  showQrcodeForm = () => {
    this.qrcodeVisible = true;
  };
}

export default new Store()
